{{define "infoCollection/ccRiskRating.html"}}
    <div class="box box-info">
        <div class="box-header with-border">
            <h3 class="box-title">心脑血管风险评级</h3>
        </div>
        <form class="form-horizontal" id="ccRiskRatingForm">
            <div class="box-body">
                <div class="form-group">
                    <label class="col-sm-3 control-label">
                        高血压：
                    </label>
                    <div class="radio col-sm-9">
                        <input type="radio" name="fengxianpingji_gaoxueya" value="有" class="minimal">&nbsp;&nbsp;有&nbsp;&nbsp;
                        <input type="radio" name="fengxianpingji_gaoxueya" value="无" class="minimal" checked>&nbsp;&nbsp;无
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label">
                        血脂异常：
                    </label>
                    <div class="radio col-sm-9">
                        <input type="radio" name="fengxianpingji_xzyc" value="是" class="minimal">&nbsp;&nbsp;是&nbsp;&nbsp;
                        <input type="radio" name="fengxianpingji_xzyc" value="否" class="minimal" checked>&nbsp;&nbsp;否
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">
                        糖尿病：
                    </label>
                    <div class="radio col-sm-9">
                        <input type="radio" name="fengxianpingji_tnb" value="有" class="minimal">&nbsp;&nbsp;有&nbsp;&nbsp;
                        <input type="radio" name="fengxianpingji_tnb" value="无" class="minimal" checked>&nbsp;&nbsp;无
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">
                        房颤或瓣膜性心脏病：
                    </label>
                    <div class="radio col-sm-9">
                        <input type="radio" name="fengxianpingji_fc" value="有" class="minimal">&nbsp;&nbsp;有&nbsp;&nbsp;
                        <input type="radio" name="fengxianpingji_fc" value="无" class="minimal" checked>&nbsp;&nbsp;无
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">
                        吸烟史：
                    </label>
                    <div class="radio col-sm-9">
                        <input type="radio" name="fengxianpingji_xiyan" value="有" class="minimal">&nbsp;&nbsp;有&nbsp;&nbsp;
                        <input type="radio" name="fengxianpingji_xiyan" value="无" class="minimal" checked>&nbsp;&nbsp;无
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">
                        明显超重或肥胖：
                    </label>
                    <div class="radio col-sm-9">
                        <input type="radio" name="fengxianpingji_chaozhong" value="是" class="minimal">&nbsp;&nbsp;是&nbsp;&nbsp;
                        <input type="radio" name="fengxianpingji_chaozhong" value="否" class="minimal" checked>&nbsp;&nbsp;否
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">
                        运动缺乏：
                    </label>
                    <div class="radio col-sm-9">
                        <input type="radio" name="fengxianpingji_yundong" value="是" class="minimal">&nbsp;&nbsp;是&nbsp;&nbsp;
                        <input type="radio" name="fengxianpingji_yundong" value="否" class="minimal" checked>&nbsp;&nbsp;否
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">
                        脑卒中家族史：
                    </label>
                    <div class="radio col-sm-9">
                        <input type="radio" name="fengxianpingji_naocuzhong_family_history" value="有" class="minimal">&nbsp;&nbsp;有&nbsp;&nbsp;
                        <input type="radio" name="fengxianpingji_naocuzhong_family_history" value="无" class="minimal"
                               checked>&nbsp;&nbsp;无
                    </div>
                </div>

                <div class="form-group" id="pastApoplexy">
                    <label class="col-sm-3 control-label">
                        <span style="color: red;font-weight: bold;">既往脑卒中：</span>
                    </label>
                    <div class="radio col-sm-9">
                        <input type="radio" name="fengxianpingji_naocuzhong_history" value="有" class="minimal">&nbsp;&nbsp;有&nbsp;&nbsp;
                        <input type="radio" name="fengxianpingji_naocuzhong_history" value="无" class="minimal" checked>&nbsp;&nbsp;无
                    </div>
                </div>
                <div class="form-group" id="tia">
                    <label class="col-sm-3 control-label">
                        <span style="color: red;font-weight: bold;">既往短暂性脑缺血发作(TIA)：</span>
                    </label>
                    <div class="radio col-sm-9">
                        <input type="radio" name="fengxianpingji_TIA_history" value="有" class="minimal">&nbsp;&nbsp;有&nbsp;&nbsp;
                        <input type="radio" name="fengxianpingji_TIA_history" value="无" class="minimal" checked>&nbsp;&nbsp;无
                    </div>
                </div>
                <hr style="height:1px;border:none;border-top:1px solid #f4f4f4;margin-top: 0;margin-bottom: 0;"/>
                <div class="form-group" style="margin-top: 15px;">
                    <label class="col-sm-3 control-label">
                        风险分级：
                    </label>
                    <div class="input-group input-group-sm col-xs-9">
                        <div class="input-group-btn">
                            <button type="button" id="fengxiandengji_result_gaowei" class="btn  btn-default btn-lg">高危
                            </button>
                            <button type="button" id="fengxiandengji_result_zhongwei" class="btn  btn-default btn-lg">中危
                            </button>
                            <button type="button" id="fengxiandengji_result_diwei" class="btn  btn-default btn-lg">低危
                            </button>
                        </div>
                    </div>
                </div>
                <div class="form-group" style="font-size: 10px;color: red;font-weight: bold;">
                    <label class="col-sm-3 control-label">&nbsp;</label>
                    <div class="col-sm-9">
                        1.高危:患有"脑卒中或者TIA"或者除二者之外的其他危险因素项目数量大于等于3。<br>
                        2.中危:有高血压、糖尿病、房颤或者瓣膜性心脏病三种慢性病之一。<br>
                        3.低危:具有三项以下危险因素且无高血压、糖尿病、心房颤动或者瓣膜性心脏病等慢性疾病。
                    </div>

                </div>
            </div>
            <div class="box-footer">
                <!--<button type="button" class="btn btn-info btn-lg middleBtn" id="saveCcRiskRating">保存</button>-->
            </div>
        </form>
    </div>
    <script>

        $(function () {
            /*$("#saveCcRiskRating").click(function () {
                return;
                let d = {};
                let t = $('#ccRiskRatingForm').serializeArray();
                let risk_number = 0;
                $.each(t, function () {
                    d[this.name] = this.value;
                    if ((this.name != "fengxianpingji_naocuzhong_history" && this.name != "fengxianpingji_TIA_history") && (this.value == "有" || this.value == "是")) {
                        risk_number++;
                    }
                });


                if (d["fengxianpingji_naocuzhong_history"] == "有" || d["fengxianpingji_TIA_history"] == "有") {
                    d["risk_level"] = "高危";
                    d["risk_reason"] = "有脑卒中或者TIA";
                } else if (risk_number >= 3) {
                    d["risk_level"] = "高危";
                    d["risk_reason"] = "患有除脑卒中和TIA之外的其他危险因素项目数量大于等于3";
                } else if (risk_number < 3) {
                    if (d["fengxianpingji_gaoxueya"] == "有" || d["fengxianpingji_tnb"] == "有" || d["fengxianpingji_fc"] == "有") {
                        d["risk_level"] = "中危";
                        d["risk_reason"] = "有高血压、糖尿病、房颤或者瓣膜性心脏病三种慢性病之一";
                    } else {
                        d["risk_level"] = "低危";
                        d["risk_reason"] = "具有三项以下危险因素且无高血压、糖尿病、心房颤动或者瓣膜性心脏病等慢性疾病";
                    }
                }
                alert("【风险分级】:" + d["risk_level"] + "\n【原因】:" + d["risk_reason"]);
                f1(d);
                let data = JSON.stringify(d);
                ajaxLoading("正在提交数据...");
                $.post("/infoCollection/save", {
                    type: "ccRiskRating",
                    id: $("#screenId").val(),
                    data: data
                }, function (resp) {
                    ajaxLoadEnd();
                    afterUpdateFormData(resp, "ccRiskRating");
                });
            });*/
            //-------end of saveCCriskRating click method

        });//end of $(function(){});


        function ccRiskRatingInit(ccRiskRatingData) {
            $("#ccRiskRatingForm").initForm({jsonValue: ccRiskRatingData, isDebug: false});
            let risk_number = 0;
            $.each(ccRiskRatingData, function (key,val) {
                if ((key != "fengxianpingji_naocuzhong_history" && key != "fengxianpingji_TIA_history") && (val == "有" || val == "是")) {
                    risk_number++;
                }
            });
            if (ccRiskRatingData["fengxianpingji_naocuzhong_history"] == "有" || ccRiskRatingData["fengxianpingji_TIA_history"] == "有") {
                ccRiskRatingData["risk_level"] = "高危";
                ccRiskRatingData["risk_reason"] = "有脑卒中或者TIA";
            } else if (risk_number >= 3) {
                ccRiskRatingData["risk_level"] = "高危";
                ccRiskRatingData["risk_reason"] = "患有除脑卒中和TIA之外的其他危险因素项目数量大于等于3";
            } else if (risk_number < 3) {
                if (ccRiskRatingData["fengxianpingji_gaoxueya"] == "有" || ccRiskRatingData["fengxianpingji_tnb"] == "有" || ccRiskRatingData["fengxianpingji_fc"] == "有") {
                    ccRiskRatingData["risk_level"] = "中危";
                    ccRiskRatingData["risk_reason"] = "有高血压、糖尿病、房颤或者瓣膜性心脏病三种慢性病之一";
                } else {
                    ccRiskRatingData["risk_level"] = "低危";
                    ccRiskRatingData["risk_reason"] = "具有三项以下危险因素且无高血压、糖尿病、心房颤动或者瓣膜性心脏病等慢性疾病";
                }
            }
            console.log("【风险分级】:" + ccRiskRatingData["risk_level"] + "\n【原因】:" + ccRiskRatingData["risk_reason"]);
            f1(ccRiskRatingData);
        }


        function f1(d) {
            if (d["risk_level"] == "高危") {
                f("fengxiandengji_result_gaowei");
            } else if (d["risk_level"] == "中危") {
                f("fengxiandengji_result_zhongwei");
            } else if (d["risk_level"] == "低危") {
                f("fengxiandengji_result_diwei");
            }
        }

        function f(id) {
            $("button[id^='fengxiandengji_result_']").attr("class", "btn btn-default btn-lg");
            $("#" + id).removeClass("btn-default");
            $("#" + id).addClass("btn-danger");
        }

    </script>
{{end}}